#include <iostream>
using namespace std;
int n, k;
int a[41];
int cnt[2101];
int res;
static bool is_prime(int n)
{
	if (n < 2)return false;
	
	for (int i = 2; i * i <= n; ++i) 
	{
		if (n % i == 0)return false;
	}
	return true;
}
void dfs(int x,int start)
{
	if (x > k)
	{
		int sum = 0;
		for (int i = 1; i <= k; i++)
		{
			sum += cnt[i];
		}
		if (is_prime(sum))
		{
			res++;
		}
		return;
	}
	for (int i = start; i <= n; i++)
	{
		cnt[x] = a[i];
		dfs(x + 1, i + 1);
		cnt[x] = 0;
	}
}
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	dfs(1,1);
	cout << res <<endl;
	return 0;
}
